import pandas as pd
import numpy as np
from collections import OrderedDict
import re
import string
def clean(s):
    """ Preprocess log message
    Parameters
    ----------
    s: str, raw log message

    Returns
    -------
    str, preprocessed log message without number tokens and special characters
    """
    # s = re.sub(r'(\d+\.){3}\d+(:\d+)?', " ", s)
    # s = re.sub(r'(\/.*?\.[\S:]+)', ' ', s)
    s = re.sub('\]|\[|\)|\(|\=|\,|\;', ' ', s)
    print(s)
    s = " ".join([word.lower() if word.isupper() else word for word in s.strip().split()])
    print(s)
    s = re.sub('([A-Z][a-z]+)', r' \1', re.sub('([A-Z]+)', r' \1', s))
    print(s)
    s = " ".join([word for word in s.split() if not bool(re.search(r'\d', word))])
    print(s)
    trantab = str.maketrans(dict.fromkeys(list(string.punctuation)))
    content = s.translate(trantab)
    print(s)
    s = " ".join([word.lower().strip() for word in content.strip().split()])
    print(s)
    return s

str="081109 203615 148 INFO dfs.DataNode$PacketResponder: PacketResponder 1 for block blk_38865049064139660 terminating"
clean(str)